/**
 * @description 导出组件
 * @author wangjianjun
 */

import React, { Component } from 'react';
import { PrimaryGhostC } from '../../../comps';
import { stringify } from 'qs';
import PropTypes from 'prop-types';
import { exportFile } from '../../../utils/commonFunc';

class ExportC extends Component {
  // 默认值
  static defaultProps = {
    disabled: false, //默认不禁止
    url: '', // 导出的接口url
    search: {}, // 导出条件
    style: {}, // 样式
    title: '导出', // 标题
  };

  export = () => {
    const { search, url } = this.props;
    exportFile(url, search);
  };

  render() {
    const { disabled, style, title } = this.props;

    return (
      <div style={style}>
        <PrimaryGhostC title={title} disabled={disabled} onClick={this.export} />
      </div>
    );
  }
}
// props默认值
ExportC.propsTypes = {
  url: PropTypes.string, // 导出的接口url
  search: PropTypes.object, // 导出条件
  disabled: PropTypes.bool, // 禁用
  style: PropTypes.object, // 样式
  title: PropTypes.string, // 标题
};

export default ExportC;
